 
<?php $Dir=$_GET['Dir'];
	$form=$_GET['form'];
 $dir="../hinhanh/".$Dir;?>


<html>

<head>
<meta http-equiv="Content-Language" content="en-us">
<meta name="GENERATOR" content="Microsoft FrontPage 6.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Chọn ảnh</title>
<link href="include/AdminCSS.css" rel="stylesheet" type="text/css">
<script language="javascript">
<!--
function selectImg()
{
	var strSrc="<?php echo $dir;?>/"+document.frmImg.cbImgList.value;
	document.all['imgDIV'].innerHTML="<img id=\"imgPre\" src=\""+strSrc+"\">"
	//document.frmImg.imgPre.src="<%=poolDir%>"+document.frmImg.cbImgList.value;
	document.frmImg.txtImg.value=document.frmImg.cbImgList.value;
	document.frmImg.txtWidth.value=document.frmImg.imgPre.width;
	document.frmImg.txtHeight.value=document.frmImg.imgPre.height;
	document.frmImg.txtWidth2.value="";
	document.frmImg.txtHeight2.value="";
}

selectImg();
function rate()
{
	var intWidth = 0;
	var intHeight = 0;
	var fltRate = 1;
	intWidth = parseInt(document.frmImg.txtWidth.value);
	intHeight = parseInt(document.frmImg.txtHeight.value);
	fltRate = intWidth/intHeight;
	return fltRate;
}
function doIt(obj1,obj2)
{
	var intValue;
	var intCur;
	var intFar;
	intCur=parseInt(obj1.value);
	if(obj2=="h"){
		intFar=parseInt(intCur/rate());
		document.frmImg.txtHeight2.value=""+intFar;
		document.frmImg.imgPre.height=intFar;
		document.frmImg.imgPre.width=intCur;
	}
	else{
		intFar=parseInt(intCur*rate());
		document.frmImg.txtWidth2.value=""+intFar;
		document.frmImg.imgPre.width=intFar;
		document.frmImg.imgPre.height=intCur;
	}
}
//-->
</script>
<script language="javascript">
<!--
function askconf(strMess){
	var yn;
	yn=window.confirm(strMess);
	if (yn==true){
		return true;
		}
	return false;
}

function insertPic(strValue){
	var strValue="<?php echo $dir;?>/"+document.frmImg.cbImgList.value;
	window.opener.document.frmdanhsach.<?php echo $form;?>.value=strValue;
//	window.opener.document.frmDanhSach.anhmota.src=strValue;
}
function openWindow2(url) {
  popupWin = window.open(url,'new_page','width=500,height=220')
}
//-->
</script>
</head>

<body>

<center><table border="0" width="400" style="border-collapse: collapse">
  <form name="frmImg" method="post" action>
     <tr>
         <td valign="top" colspan="2" align="center" height="30"><b>CÁC ẢNH FILE TẢI LÊN</b></td>
     </tr>
     <tr>
         <td valign="top"><select size="15" name="cbImgList" style="width:200" onChange="selectImg();">
       <?php
		$row=scandir($dir);
		$value=count($row);
		echo "<br>";
		$i=2;
		foreach ($row as $value)
		{?>
		   <option value="<?php echo $row[$i];?>" <?php if(i==2){?> selected <?php }?> ><?php echo $row[$i];?></option>
		<?php 
		$i=$i+1;
		}
		
		?>
        </select> </td>
         <td valign="top"><table border="0" style="border-collapse: collapse" width="100%">
          <tr>
              <td align="center">
               <div id="imgDIV">
                  <img id="imgPre" border="0" src="../images/spacer.gif" style="border: 1px solid #000000"></div>
              </td>
          </tr>
          <tr>
              <td align="center" style="padding-top: 5px">
               <table border="0" cellpadding="0" cellspacing="0" width="100%" style="border: 1px solid #C0C0C0">
                 <tr>
                     <td align="center">Width:</td>
                     <td align="center"><input type="text" name="txtWidth" size="5" class="textbox" style="width:40px"></td>
                     <td align="center">Height:</td>
                     <td align="center"><input type="text" name="txtHeight" size="5" class="textbox" style="width:40px"></td>
                 </tr>
               </table>

              </td>
          </tr>
          </table>

         </td>
     </tr>
     <tr>
         <td colspan="2" align="center" style="padding-top: 10px">
          <input type="button" value="Chọn " name="btnInsert" class="input" onClick="insertPic();window.close();">&nbsp;          
          <input type="hidden" name="txtImg"></td>
     </tr>
  </form>
</table>

</center>


</body>

</html>
